package main

import (
	"fmt"
	"imgtools/command"
	"os"
	"time"

	"github.com/urfave/cli/v2"
)

var (
	// 当前版本号
	version = ""
	// 编译时间
	buildtime = ""
	// 应用名
	appname = ""
)

func main() {
	app := cli.NewApp()
	app.Usage = "image tools"
	app.Flags = []cli.Flag{}
	app.Commands = []*cli.Command{
		command.JPG,
		command.Cut,
	}

	app.CommandNotFound = func(cCtx *cli.Context, command string) {
		fmt.Fprintf(cCtx.App.Writer, "[ERROR]没有[%s]\n", command)
	}
	if version == "" {
		version = "development"
	}
	if buildtime == "" {
		buildtime = time.Now().Format("20060102150405")
	}
	app.Version = version + "(" + buildtime + ")"
	app.Run(os.Args)

}
